﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace QuanLyNhaSach.DataAccessLayer
{
    public class TonKhoDAO
    {
        DataConnection dt_con = new DataConnection();
        public TonKhoDAO()
        {

        }
        public DataTable LayDanhSach()
        {
            return dt_con.Read("select * from TONKHO");
        }

        public void ThemPhieuTon(string maTK, string ngayLap)
        {
            string cmd = "exec TONKHO_insert '{0}','{1}'";
            dt_con.Write(String.Format(cmd, maTK, ngayLap));
        }

        public void ThemCTT(string maTK, string maSach, int tonDau, int phatSinh, int tonCuoi)
        {
            string cmd = "exec CTTON_insert '{0}', '{1}', {2}, {3}, {4}";
            dt_con.Write(String.Format(cmd, maTK, maSach, tonDau, phatSinh, tonCuoi));
        }

        public DataTable LayBaoCaoTon(string thangBC)
        {
            string cmd = "exec TONKHO_Get '" + thangBC+ "'";
            return dt_con.Read(String.Format(cmd));
        }
    }
}
